package com.example.zhaojianxu.signin.englishgame.recording

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
import com.example.zhaojianxu.signin.R
import com.example.zhaojianxu.signin.englishgame.http.EGRecordEntity

/**
 * create by @zhaojianxu on 2019/2/26
 */
class RecordAdapter: RecyclerView.Adapter<RecordViewHolder>(){

    private var mList = mutableListOf<EGRecordEntity>()

    fun bindData(list: MutableList<EGRecordEntity>){
        mList.clear()
        mList.addAll(list)
        notifyDataSetChanged()
    }

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecordViewHolder {
        val view = LayoutInflater.from(parent?.context).inflate(R.layout.item_record_view,parent,false)
        return RecordViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: RecordViewHolder?, position: Int) {
        holder?.bindData(mList[position])
    }

}